package top.lshaci.learning.jvm.string;

import java.io.BufferedReader;
import java.io.FileReader;

/**
 * StringTableSizeTest
 *
 * @author lshaci
 * @date 2020/7/16 9:08
 * @since 1.0.0
 */
public class StringTableSizeTest {

    /**
     * -XX:StringTableSize=60013  54ms
     * -XX:StringTableSize=1009   347ms
     * -XX:StringTableSize=1000   StringTable size of 1000 is invalid; must be between 1009 and 2305843009213693951
     */
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new FileReader("words.txt"));
        String s;
        long start = System.currentTimeMillis();
        while ((s = br.readLine()) != null) {
            s.intern(); // 如果字符串常量池中没有对应的s的字符串的话，则在字符串常量池中生成
        }
        long end = System.currentTimeMillis();
        System.err.println("花费时间：" + (end - start) + "ms");
    }
}
